import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ApplyVO, ApplyForm, ApplyQuery } from '@/api/order/apply/types';

/**
 * 查询应用列表
 * @param query
 * @returns {*}
 */

export const listApply = (query?: ApplyQuery): AxiosPromise<ApplyVO[]> => {
    return request({
        url: '/order/apply/list',
        method: 'get',
        params: query
    });
};

/**
 * 查询应用详细
 * @param id
 */
export const getApply = (id: string | number): AxiosPromise<ApplyVO> => {
    return request({
        url: '/order/apply/' + id,
        method: 'get'
    });
};

/**
 * 新增应用
 * @param data
 */
export const addApply = (data: ApplyForm) => {
    return request({
        url: '/order/apply',
        method: 'post',
        data: data
    });
};

/**
 * 修改应用
 * @param data
 */
export const updateApply = (data: ApplyForm) => {
    return request({
        url: '/order/apply',
        method: 'put',
        data: data
    });
};

/**
 * 删除应用
 * @param id
 */
export const delApply = (id: string | number | Array<string | number>) => {
    return request({
        url: '/order/apply/' + id,
        method: 'delete'
    });
};

export default {
    list: listApply,
    get: getApply,
    add: addApply,
    update: updateApply,
    del: delApply,
}